package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 87111
 * Date: 2025-06-24
 * Time: 9:08
 */
public class Test01 {
    public static void main(String[] args) {
        OuterClass outerClass = new OuterClass();
        outerClass.test01();
    }
}

class OuterClass {
    public void test01() {

//        Animal dog = new Animal("旺财") {
//            public void eat() {
//                System.out.println(super.name + "吃香肠");
//            }
//        };
//        dog.eat();

        new Animal("旺财") {
            public void eat() {
                System.out.println(super.name + "吃香肠");
            }
        }.eat();
    }
}

class Animal {
    public String name;
    public Animal(String name) {
        this.name = name;
        System.out.println("name");
    }
    public void eat() {
        System.out.println(this.name + "吃食物");
    }
}

//class Dog extends Animal {
//    public Dog(String name) {
//        super(name);
//    }
//    public void eat() {
//        System.out.println(super.name + "吃香肠");
//    }
//}